// 导入Vue
import Vue from 'vue'
// 导入路由这个插件
import VueRouter from 'vue-router'
// 导入组件
import one from '@/views/one'
import two from '@/views/two'
import three from '@/views/three'

// 让Vue安装路由--让vue拥有路由的一些功能
Vue.use(VueRouter)

// 制定路由规则
const routes = [
  // 以后用路径`/`，就能访问HomeView这个组件
  {
    path: '/one',
    name: 'one',
    component: one
  },
  {
    path: '/two',
    name: 'two',
    component: two
  },
  {
    path: '/three/:name/:age',
    name: 'three',
    component: three
  }
]

// 实例化路由对象，并设置规则
const router = new VueRouter({
  routes
})

// 把路由对象暴露出去了
export default router
